﻿using MediatR;
using S.Services.SheepMale.Api.Application.Command.PurchaseCommand;
using S.Services.SheepMale.Domain.PurchaseSales;
using S.Services.SheepMale.Infrastructure;

namespace S.Services.SheepMale.Api.Application.CommandHandler.PurchaseCommandHandler
{
    public class PurchaseDelCommandHandler : IRequestHandler<PurchaseDelCommand, int>
    {
        private readonly IRepository<EntityPurchase> repository;
        
        public PurchaseDelCommandHandler(IRepository<EntityPurchase> repository)
        {
            this.repository = repository;
        }
        public async Task<int> Handle(PurchaseDelCommand request, CancellationToken cancellationToken)
        {
            return await repository.DeleteAsync(request.purId);
        }
    }
}
